<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
	
<ui:composition template="/pages/template/padrao.xhtml">
<ui:define name="principal">
	<f:view>
	<center>
		<!-- Nova Categoria -->
		<h:form>
			<h:commandLink value="Nova Categoria" action="#{controlCategoria.mostrarNovo}" />
		</h:form>
		<h:form id="novaCategoria" binding="#{controlCategoria.formNovo}" rendered="false">
			<h:panelGrid columns="2">
				<h:outputText value="Nome" />
				<h:inputText id="nome" value="#{controlCategoria.categoria.nome}" required="true" />
			</h:panelGrid>
			<h:panelGroup>
				<h:commandButton value="Inserir" action="#{controlCategoria.inserir}" />
			</h:panelGroup>
		</h:form>
		
		<h:messages />

		<!-- Lista de Categoria -->
		<h:form>
			<h:dataTable value="#{controlCategoria.listaCategorias}" var="cat" border="1">
				<f:facet name="header">
					<h:outputText value="Categorias" />
				</f:facet>
				<h:column>
					<f:facet name="header">
						<h:outputText value="Nome" />
					</f:facet>
					<h:outputText value="#{cat.nome}" />
				</h:column>
				
				<h:column>
					<f:facet name="header">
						<h:outputText value="Excluir" />
					</f:facet>
					<h:commandLink value="Excluir" action="#{controlCategoria.excluir}">
						<f:setPropertyActionListener value="#{cat}" target="#{controlCategoria.categoria}"/>
					</h:commandLink>
				</h:column>
			</h:dataTable>
			<h:messages style="color:red" /> 
		</h:form>
		<h:outputLink value="#{facesContext.externalContext.requestContextPath}/pages/inicial.jsf" >
			<f:verbatim>Voltar</f:verbatim>
		</h:outputLink>
	</center>
	</f:view>
</ui:define>
</ui:composition>
</html>